<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="../../templates/ui2.xhtml">
    <ui:define name="title">
	Cadastrar Empresa
    </ui:define>

    <ui:define name="content">
        <div id="entryContentPanel">

            <h:form>
                <div class="entry" style="line-height: 200%">
                    <p:panel id="panel">
                        <h:panelGrid columns="3" columnClasses="label, value, error" styleClass="grid">
                            <h:outputText value="Razão"/>
                            <p:inputText value="#{empresaBean.empresa.razao}" required="true" requiredMessage="#{message.requiredMessage}" id="idRazao"
                                         size="50" maxlength="50"/>
                            <p:message for="idRazao" />

                            <h:outputText value="Fantasia" />
                            <p:inputText value="#{empresaBean.empresa.fantasia}" required="true" requiredMessage="${message.requiredMessage}" id="idFantasia"
                                         size="50" maxlength="50"/>
                            <p:message for="idFantasia" />

                            <h:outputText value="Endereco" />
                            <p:inputText value="#{empresaBean.empresa.endereco}" required="true" requiredMessage="#{message.requiredMessage}" id="idEndereco"
                                         size="50" maxlength="50"/>
                            <p:message for="idEndereco" />

                            <h:outputText value="CNPJ" />
                            <p:inputText value="#{empresaBean.empresa.cnpj}" required="true" requiredMessage="#{message.requiredMessage}" id="idCnpj"
                                         size="20" maxlength="20"/>
                            <p:message for="idCnpj" />

                            <h:outputText value="Municipal" />
                            <p:inputText value="#{empresaBean.empresa.incrMunicipal}" required="true" requiredMessage="#{message.requiredMessage}" id="idMunicipal"
                                         size="20" maxlength="20"/>
                            <p:message for="idMunicipal" />

                            <h:outputText value="Estadual" />
                            <p:inputText value="#{empresaBean.empresa.incrEstadual}" required="true" requiredMessage="#{message.requiredMessage}" id="idEstadual"
                                         size="20" maxlength="20"/>
                            <p:message for="idEstadual" />

                            <h:outputText value="Status" />
                            <h:selectOneMenu value="#{usuarioBean.usuario.status}" >
                                <f:selectItem itemValue="A" itemLabel="Ativo" />
                                <f:selectItem itemValue="I" itemLabel="Inativo" />
                            </h:selectOneMenu>
                            <h:outputText />

                            <p:commandButton value="Cadastrar"  action="#{empresaBean.cadastraEmpresa}"
                                             update="panel, panel2, oplDialog" type="submit" ajax="false"/>

                            <p:spacer width="1"/>

                            <p:commandButton value="Limpar"  type="reset" />
                        </h:panelGrid>
                    </p:panel>
                    <br/>
                    <br/>

                    <!-- Esse ajax em baixo não é tão legal quanto o de baixo. Fica para aprovação de vcs. -->
                    <p:ajaxStatus style="width:16px;height:16px;" >
                        <f:facet name="start">
                            <h:graphicImage value="/design/ajaxloading.gif" />
                        </f:facet>

                        <f:facet name="complete" >
                            <h:outputText value=""/>
                        </f:facet>
                    </p:ajaxStatus>

                    <!-- Esse ajax aqui é legal
                    < p : ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
    		<p : dialog modal="true" widgetVar="statusDialog" header="Aguarde..."    
       			draggable="false" closable="false" >  
			<p : graphicImage value="/design/ajaxloadingbar.gif" />  
		</p :  dialog>
                    -->
                </div>

            </h:form>


        </div>
    </ui:define>
</ui:composition>